﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;

namespace SEO.Spider
{
    /// <summary>
    /// 版权所有: 版权所有(C) 2011，Adin Lee
    /// 内容摘要: 查询搜索引擎收入结果类
    /// 完成日期：2011年6月2日
    /// 版    本：V1.0 
    /// 作    者：Adin
    /// </summary>
    public class SearchEnginesResult
    {
        /// <summary>
        /// 根据网址获取网站收录结果
        /// </summary>
        /// <param name="strWebUrl">网址</param>
        /// <returns>返回网站收录结果数组</returns>
        public static string[] GetRestult(string strWebUrl)
        {
            try
            {
                strWebUrl = "http://www.haiphp.com/search.php?URL=http%3A%2F%2F" + strWebUrl + "&Submity=%B2%E9++%D1%AF";
                SEO.Utility.WebClient wc = new SEO.Utility.WebClient();
                wc.Encoding = System.Text.Encoding.GetEncoding("gbk");
                wc.OpenRead(strWebUrl);
                string strGetHtmlCode = wc.RespHtml;
                Regex rx = new Regex("<table class=\"prtable\">(?<content>[\\s\\S]*)?<div class=\"left_site_content\">", RegexOptions.Singleline);
                string strGetResult = rx.Match(strGetHtmlCode).Result("${content}");
                strGetResult = strGetResult.Replace("</td>", "|");
                strGetResult = SEO.Utility.StringHelper.CleanHtml(strGetResult);
                strGetResult = strGetResult.Replace("\r", "");
                strGetResult = strGetResult.Replace("\n", "");
                strGetResult = strGetResult.Replace("\t", "");
                //Alexa 排名|1713761&nbsp;详细查看|Google PR值|6|Baidu 收录|Google 收录|YAHOO 收录|SOSO 收录|Youdao 收录|246|4690|6450|2680|0| 延伸查询|百度收录查询&nbsp;&nbsp;Alexa排名查询&nbsp;&nbsp;Google PR查询|
                string[] splitResult = strGetResult.Split(new char[] { '|' });
                //Alexa 排名
                string strAlexaRank = splitResult[1];
                strAlexaRank = strAlexaRank.Replace("&nbsp;", "");
                strAlexaRank = strAlexaRank.Replace("详细查看", "");
                //Google PR值
                string strGooglePR = splitResult[3];
                string strBaidu = splitResult[9];
                string strGoogle = splitResult[10];
                string strYahoo = splitResult[11];
                string strSoso = splitResult[12];
                string strYoudao = splitResult[13];
                string[] splitArray = { strGooglePR, strBaidu, strGoogle, strYahoo, strSoso, strYoudao, strAlexaRank };

                return splitArray;
            }
            catch (Exception ex)
            {
                SEO.Utility.Log.SaveErrorLog("根据网址获取网站收录结果 -> " + ex.Message);
                return null;
            }
            
        }

        public static string GetRestultByUrl(string strWebUrl)
        {
            string strReturnValue = "";

            try
            {
                strWebUrl = "http://google.55.la/google.php?domain=" + strWebUrl;
                SEO.Utility.WebClient wc = new SEO.Utility.WebClient();
                wc.Encoding = System.Text.Encoding.GetEncoding("gbk");
                wc.OpenRead(strWebUrl);
                string strGetHtmlCode = wc.RespHtml;
                Regex rx = new Regex("<font color=\"#666666\">(?<content>[\\s\\S]*)?</font>", RegexOptions.Singleline);
                string strGetResult = rx.Match(strGetHtmlCode).Result("${content}");
                strGetResult = strGetResult.Replace("&nbsp;", "");
                
                return strReturnValue;
            }
            catch (Exception ex)
            {
                SEO.Utility.Log.SaveErrorLog("根据网址获取网站收录结果 -> " + ex.Message);
                return null;
            }

        }

        /// <summary>
        /// 百度：根据网址获取百度收录结果条数
        /// </summary>
        /// <param name="strWebUrl">网址</param>
        /// <returns>返回收录结果数目</returns>
        public static string GetBaiDuResultNumByWebsite(string strWebUrl)
        {
            string strGetResult = "0";

            try
            {
                strWebUrl = "http://www.baidu.com/s?wd=site%3A" + strWebUrl;
                SEO.Utility.WebClient wc = new SEO.Utility.WebClient();
                wc.Encoding = System.Text.Encoding.GetEncoding("gb2312");
                wc.OpenRead(strWebUrl);
                string strGetHtmlCode = wc.RespHtml;
                Regex rx = new Regex("<p id=\"page\">(?<content>[\\s\\S]*)?<div id=\"search\">", RegexOptions.Singleline);
                strGetResult = rx.Match(strGetHtmlCode).Result("${content}");

                Regex rxNum = new Regex("找到相关结果(?<content>[\\s\\S]*)?个", RegexOptions.Singleline);
                strGetResult = rxNum.Match(strGetResult).Result("${content}");
                strGetResult = strGetResult.Replace("约","");
            }
            catch (Exception ex)
            {
                SEO.Utility.Log.SaveErrorLog("抓取百度搜索结果入口 -> " + ex.Message);
            }

            return strGetResult;
        }

        /// <summary>
        /// 百度：根据网址获取该网址的反向链接
        /// </summary>
        /// <param name="strWebUrl">网址</param>
        /// <returns>返回该网址的反向链接数目</returns>
        public static string GetBaiDuResultNumByLinks(string strWebUrl)
        {
            string strGetResult = "0";

            try
            {
                SEO.Utility.WebClient wc = new SEO.Utility.WebClient();
                wc.Encoding = System.Text.Encoding.GetEncoding("gb2312");
                wc.OpenRead(strWebUrl);
                string strGetHtmlCode = wc.RespHtml;
                Regex rx = new Regex("<p id=\"page\">(?<content>[\\s\\S]*)?<div id=\"search\">", RegexOptions.Singleline);
                strGetResult = rx.Match(strGetHtmlCode).Result("${content}");

                Regex rxNum = new Regex("找到相关结果(?<content>[\\s\\S]*)?个", RegexOptions.Singleline);
                strGetResult = rxNum.Match(strGetResult).Result("${content}");
                strGetResult = strGetResult.Replace("约", "");
            }
            catch (Exception ex)
            {
                SEO.Utility.Log.SaveErrorLog("抓取百度搜索结果入口 -> " + ex.Message);
            }

            return strGetResult;
        }

        /// <summary>
        /// 谷歌：根据网址获取谷歌收录结果条数
        /// </summary>
        /// <param name="strWebUrl">网址</param>
        /// <returns>返回收录结果数目</returns>
        public static string GetGoogleResultNumByWebsite(string strWebUrl)
        {
            string strGetResult = "0";

            try
            {
                strWebUrl = "http://www.google.com.hk/search?hl=zh-CN&q=site%3A" + strWebUrl;
                SEO.Utility.WebClient wc = new SEO.Utility.WebClient();
                wc.Encoding = System.Text.Encoding.UTF8;
                wc.OpenRead(strWebUrl);
                string strGetHtmlCode = wc.RespHtml;
                Regex rx = new Regex("<div id=resultStats>(?<content>[\\s\\S]*)?<div id=\"ucs\">", RegexOptions.Singleline);
                strGetResult = rx.Match(strGetHtmlCode).Result("${content}");

                Regex rxNum = new Regex("找到约(?<content>[\\s\\S]*)?条结果", RegexOptions.Singleline);
                strGetResult = rxNum.Match(strGetResult).Result("${content}");
                strGetResult = strGetResult.Trim();
            }
            catch (Exception ex)
            {
                SEO.Utility.Log.SaveErrorLog("抓取谷歌搜索结果入口 -> " + ex.Message);
            }

            return strGetResult;
        }

        /// <summary>
        /// 谷歌：根据网址获取该网址的反向链接
        /// </summary>
        /// <param name="strWebUrl">网址</param>
        /// <returns>返回该网址的反向链接数目</returns>
        public static string GetGoogleResultNumByLinks(string strWebUrl)
        {
            string strGetResult = "0";

            try
            {
                SEO.Utility.WebClient wc = new SEO.Utility.WebClient();
                wc.Encoding = System.Text.Encoding.GetEncoding("gb2312");
                wc.OpenRead(strWebUrl);
                string strGetHtmlCode = wc.RespHtml;
                Regex rx = new Regex("<p id=\"page\">(?<content>[\\s\\S]*)?<div id=\"search\">", RegexOptions.Singleline);
                strGetResult = rx.Match(strGetHtmlCode).Result("${content}");

                Regex rxNum = new Regex("找到相关结果(?<content>[\\s\\S]*)?个", RegexOptions.Singleline);
                strGetResult = rxNum.Match(strGetResult).Result("${content}");
                strGetResult = strGetResult.Replace("约", "");
            }
            catch (Exception ex)
            {
                SEO.Utility.Log.SaveErrorLog("抓取百度搜索结果入口 -> " + ex.Message);
            }

            return strGetResult;
        }

        /// <summary>
        /// 搜搜：根据网址获取收录结果条数
        /// </summary>
        /// <param name="strWebUrl">网址</param>
        /// <returns>返回收录结果数目</returns>
        public static string GetSosoResultNumByWebsite(string strWebUrl)
        {
            string strGetResult = "0";

            try
            {
                strWebUrl = "http://www.soso.com/q?pid=s.idx&w=site%3A" + strWebUrl;
                SEO.Utility.WebClient wc = new SEO.Utility.WebClient();
                wc.Encoding = System.Text.Encoding.GetEncoding("gb2312");
                wc.OpenRead(strWebUrl);
                string strGetHtmlCode = wc.RespHtml;
                Regex rx = new Regex("<div id=\"sInfo\">(?<content>[\\s\\S]*)?<div id=\"main\" >", RegexOptions.Singleline);
                strGetResult = rx.Match(strGetHtmlCode).Result("${content}");

                Regex rxNum = new Regex("搜索到约(?<content>[\\s\\S]*)?项结果", RegexOptions.Singleline);
                strGetResult = rxNum.Match(strGetResult).Result("${content}");
                strGetResult = strGetResult.Trim();
            }
            catch (Exception ex)
            {
                SEO.Utility.Log.SaveErrorLog("抓取搜搜搜索结果入口 -> " + ex.Message);
            }

            return strGetResult;
        }

        /// <summary>
        /// 搜搜：根据网址获取该网址的反向链接
        /// </summary>
        /// <param name="strWebUrl">网址: 上海云里网络科技有限公司.com or www.上海云里网络科技有限公司.com</param>
        /// <returns>返回该网址的反向链接数目</returns>
        public static string GetSosoResultNumByLinks(string strWebUrl)
        {
            string strGetResult = "0";

            try
            {
                strWebUrl = "http://www.soso.com/q?pid=s.idx&w=link%3A" + strWebUrl;
                SEO.Utility.WebClient wc = new SEO.Utility.WebClient();
                wc.Encoding = System.Text.Encoding.GetEncoding("gb2312");
                wc.OpenRead(strWebUrl);
                string strGetHtmlCode = wc.RespHtml;
                Regex rx = new Regex("<div id=\"sInfo\">(?<content>[\\s\\S]*)?<div id=\"main\" >", RegexOptions.Singleline);
                strGetResult = rx.Match(strGetHtmlCode).Result("${content}");

                Regex rxNum = new Regex("搜索到约(?<content>[\\s\\S]*)?项结果", RegexOptions.Singleline);
                strGetResult = rxNum.Match(strGetResult).Result("${content}");
                strGetResult = strGetResult.Replace("约", "");
            }
            catch (Exception ex)
            {
                SEO.Utility.Log.SaveErrorLog("抓取搜搜搜索结果入口 -> " + ex.Message);
            }

            return strGetResult;
        }

        /// <summary>
        /// 有道：根据网址获取收录结果条数
        /// </summary>
        /// <param name="strWebUrl">网址</param>
        /// <returns>返回收录结果数目</returns>
        public static string GetYoudaoResultNumByWebsite(string strWebUrl)
        {
            string strGetResult = "0";

            try
            {
                strWebUrl = "http://www.youdao.com/search?q=site%3A" + strWebUrl;
                SEO.Utility.WebClient wc = new SEO.Utility.WebClient();
                wc.Encoding = System.Text.Encoding.UTF8;
                wc.OpenRead(strWebUrl);
                string strGetHtmlCode = wc.RespHtml;
                Regex rx = new Regex("<h2 id=\"pt\">(?<content>[\\s\\S]*)?<ul id=\"results\" class=\"rz\">", RegexOptions.Singleline);
                strGetResult = rx.Match(strGetHtmlCode).Result("${content}");

                if (strGetResult.Contains("共约"))
                {
                    Regex rxNum = new Regex("共约(?<content>[\\s\\S]*)?条结果", RegexOptions.Singleline);
                    strGetResult = rxNum.Match(strGetResult).Result("${content}");
                    strGetResult = strGetResult.Trim();
                }
                else
                {
                    Regex rxNum = new Regex("共(?<content>[\\s\\S]*)?条结果", RegexOptions.Singleline);
                    strGetResult = rxNum.Match(strGetResult).Result("${content}");
                    strGetResult = strGetResult.Trim();
                }
            }
            catch (Exception ex)
            {
                SEO.Utility.Log.SaveErrorLog("抓取有道搜索结果入口 -> " + ex.Message);
            }

            return strGetResult;
        }

        /// <summary>
        /// 有道：根据网址获取该网址的反向链接
        /// </summary>
        /// <param name="strWebUrl">网址: 上海云里网络科技有限公司.com or www.上海云里网络科技有限公司.com</param>
        /// <returns>返回该网址的反向链接数目</returns>
        public static string GetYoudaoResultNumByLinks(string strWebUrl)
        {
            string strGetResult = "0";

            try
            {
                strWebUrl = "http://www.youdao.com/search?q=inlink%3A" + strWebUrl;
                SEO.Utility.WebClient wc = new SEO.Utility.WebClient();
                wc.Encoding = System.Text.Encoding.UTF8;
                wc.OpenRead(strWebUrl);
                string strGetHtmlCode = wc.RespHtml;
                Regex rx = new Regex("<div id=\"sInfo\">(?<content>[\\s\\S]*)?<div id=\"main\" >", RegexOptions.Singleline);
                strGetResult = rx.Match(strGetHtmlCode).Result("${content}");

                Regex rxNum = new Regex("搜索到约(?<content>[\\s\\S]*)?项结果", RegexOptions.Singleline);
                strGetResult = rxNum.Match(strGetResult).Result("${content}");
                strGetResult = strGetResult.Replace("约", "");
            }
            catch (Exception ex)
            {
                SEO.Utility.Log.SaveErrorLog("抓取有道搜索结果入口 -> " + ex.Message);
            }

            return strGetResult;
        }

        /// <summary>
        /// 搜狗：根据网址获取收录结果条数
        /// </summary>
        /// <param name="strWebUrl">网址</param>
        /// <returns>返回收录结果数目</returns>
        public static string GetSogouResultNumByWebsite(string strWebUrl)
        {
            string strGetResult = "0";

            try
            {
                strWebUrl = "http://www.sogou.com/web?query=site%3A" + strWebUrl + "&_asf=www.sogou.com&_ast=1311185417&w=01019900&p=40040100";
                SEO.Utility.WebClient wc = new SEO.Utility.WebClient();
                wc.Encoding = System.Text.Encoding.GetEncoding("gb2312");
                wc.OpenRead(strWebUrl);
                string strGetHtmlCode = wc.RespHtml;
                Regex rx = new Regex("<div class=\"resultstats\" >(?<content>[\\s\\S]*)?</form><form", RegexOptions.Singleline);
                strGetResult = rx.Match(strGetHtmlCode).Result("${content}");

                Regex rxNum = new Regex("<span id=\"scd_num\">(?<content>[\\s\\S]*)?</span>", RegexOptions.Singleline);
                strGetResult = rxNum.Match(strGetResult).Result("${content}");
                strGetResult = strGetResult.Trim();
            }
            catch (Exception ex)
            {
                SEO.Utility.Log.SaveErrorLog("抓取搜狗搜索结果入口 -> " + ex.Message);
            }

            return strGetResult;
        }

        /// <summary>
        /// 搜狗：根据网址获取该网址的反向链接
        /// </summary>
        /// <param name="strWebUrl">网址: 上海云里网络科技有限公司.com or www.上海云里网络科技有限公司.com</param>
        /// <returns>返回该网址的反向链接数目</returns>
        public static string GetSogouResultNumByLinks(string strWebUrl)
        {
            string strGetResult = "0";

            try
            {
                strWebUrl = "http://www.sogou.com/web?query=domain%3A" + strWebUrl + "&_asf=www.sogou.com&_ast=1311185578&w=01019900&p=40040100";
                SEO.Utility.WebClient wc = new SEO.Utility.WebClient();
                wc.Encoding = System.Text.Encoding.GetEncoding("gb2312");
                wc.OpenRead(strWebUrl);
                string strGetHtmlCode = wc.RespHtml;
                Regex rx = new Regex("<div class=\"resultstats\" >(?<content>[\\s\\S]*)?</form><form", RegexOptions.Singleline);
                strGetResult = rx.Match(strGetHtmlCode).Result("${content}");

                Regex rxNum = new Regex("<span id=\"scd_num\">(?<content>[\\s\\S]*)?</span>", RegexOptions.Singleline);
                strGetResult = rxNum.Match(strGetResult).Result("${content}");
                strGetResult = strGetResult.Replace("约", "");
            }
            catch (Exception ex)
            {
                SEO.Utility.Log.SaveErrorLog("抓取搜狗搜索结果入口 -> " + ex.Message);
            }

            return strGetResult;
        }

        /// <summary>
        /// 雅虎：根据网址获取收录结果条数
        /// </summary>
        /// <param name="strWebUrl">网址</param>
        /// <returns>返回收录结果数目</returns>
        public static string GetYahooResultNumByWebsite(string strWebUrl)
        {
            string strGetResult = "0";

            try
            {
                strWebUrl = "http://siteexplorer.search.yahoo.com/search;_ylt=A0oGk.rCfydOuGcAgrNdhMkF?p=" + strWebUrl + "&y=Explore+URL&fr=sfp";
                SEO.Utility.WebClient wc = new SEO.Utility.WebClient();
                wc.Encoding = System.Text.Encoding.GetEncoding("gb2312");
                wc.OpenRead(strWebUrl);
                string strGetHtmlCode = wc.RespHtml;
                Regex rx = new Regex("<ul id=\"result-details\">(?<content>[\\s\\S]*)?<div class=\"opt-list opt-left\">", RegexOptions.Singleline);
                strGetResult = rx.Match(strGetHtmlCode).Result("${content}");

                Regex rxNum = new Regex("<li><span class=\"btn\">(?<content>[\\s\\S]*)?</span></li><li>", RegexOptions.Singleline);
                strGetResult = rxNum.Match(strGetResult).Result("${content}");
                strGetResult = strGetResult.Trim();
                //Pages (45,191)
                strGetResult = strGetResult.Replace("Pages", "");
                strGetResult = strGetResult.Replace("(", "");
                strGetResult = strGetResult.Replace(")", "");
                strGetResult = strGetResult.Trim();
            }
            catch (Exception ex)
            {
                SEO.Utility.Log.SaveErrorLog("抓取雅虎搜索结果入口 -> " + ex.Message);
            }

            return strGetResult;
        }

        /// <summary>
        /// 雅虎：根据网址获取该网址的反向链接
        /// </summary>
        /// <param name="strWebUrl">网址: 上海云里网络科技有限公司.com or www.上海云里网络科技有限公司.com</param>
        /// <returns>返回该网址的反向链接数目</returns>
        public static string GetYahooResultNumByLinks(string strWebUrl)
        {
            string strGetResult = "0";

            try
            {
                strWebUrl = "http://www.sogou.com/web?query=domain%3A" + strWebUrl + "&_asf=www.sogou.com&_ast=1311185578&w=01019900&p=40040100";
                SEO.Utility.WebClient wc = new SEO.Utility.WebClient();
                wc.Encoding = System.Text.Encoding.GetEncoding("gb2312");
                wc.OpenRead(strWebUrl);
                string strGetHtmlCode = wc.RespHtml;
                Regex rx = new Regex("<ul id=\"result-details\">(?<content>[\\s\\S]*)?<div class=\"opt-list opt-left\">", RegexOptions.Singleline);
                strGetResult = rx.Match(strGetHtmlCode).Result("${content}");

                Regex rxNum = new Regex("Inlinks(?<content>[\\s\\S]*)?</a></li></ul></div><div", RegexOptions.Singleline);
                strGetResult = rxNum.Match(strGetResult).Result("${content}");
                strGetResult = strGetResult.Replace("约", "");
                strGetResult = strGetResult.Trim();
            }
            catch (Exception ex)
            {
                SEO.Utility.Log.SaveErrorLog("抓取雅虎搜索结果入口 -> " + ex.Message);
            }

            return strGetResult;
        }

        /// <summary>
        /// 必应：根据网址获取收录结果条数
        /// </summary>
        /// <param name="strWebUrl">网址</param>
        /// <returns>返回收录结果数目</returns>
        public static string GetBingResultNumByWebsite(string strWebUrl)
        {
            string strGetResult = "0";

            try
            {
                strWebUrl = "http://cn.bing.com/search?q=site%3A" + strWebUrl + "&go=&qs=n&sk=&form=QBLH";
                SEO.Utility.WebClient wc = new SEO.Utility.WebClient();
                wc.Encoding = System.Text.Encoding.UTF8;
                wc.OpenRead(strWebUrl);
                string strGetHtmlCode = wc.RespHtml;
                Regex rx = new Regex("<span class=\"sb_count\" id=\"count\">(?<content>[\\s\\S]*)?</span><span class=\"sc_bullet\">", RegexOptions.Singleline);
                strGetResult = rx.Match(strGetHtmlCode).Result("${content}");

                Regex rxNum = new Regex("共(?<content>[\\s\\S]*)?条", RegexOptions.Singleline);
                strGetResult = rxNum.Match(strGetResult).Result("${content}");
                strGetResult = strGetResult.Replace(" ", "");
                strGetResult = strGetResult.Trim();
               
            }
            catch (Exception ex)
            {
                SEO.Utility.Log.SaveErrorLog("抓取必应搜索结果入口 -> " + ex.Message);
            }

            return strGetResult;
        }

        /// <summary>
        /// 必应：根据网址获取该网址的反向链接
        /// </summary>
        /// <param name="strWebUrl">网址: 上海云里网络科技有限公司.com or www.上海云里网络科技有限公司.com</param>
        /// <returns>返回该网址的反向链接数目</returns>
        public static string GetBingResultNumByLinks(string strWebUrl)
        {
            string strGetResult = "0";

            try
            {
                strWebUrl = "http://cn.bing.com/search?q=link%3A" + strWebUrl + "&go=&qs=n&sk=&form=QBLH";
                SEO.Utility.WebClient wc = new SEO.Utility.WebClient();
                wc.Encoding = System.Text.Encoding.UTF8;
                wc.OpenRead(strWebUrl);
                string strGetHtmlCode = wc.RespHtml;
                Regex rx = new Regex("<span class=\"sb_count\" id=\"count\">(?<content>[\\s\\S]*)?</span><span class=\"sc_bullet\">", RegexOptions.Singleline);
                strGetResult = rx.Match(strGetHtmlCode).Result("${content}");

                Regex rxNum = new Regex("共(?<content>[\\s\\S]*)?条", RegexOptions.Singleline);
                strGetResult = rxNum.Match(strGetResult).Result("${content}");
                strGetResult = strGetResult.Replace(" ", "");
                strGetResult = strGetResult.Trim();
            }
            catch (Exception ex)
            {
                SEO.Utility.Log.SaveErrorLog("抓取必应搜索结果入口 -> " + ex.Message);
            }

            return strGetResult;
        }

        /// <summary>
        /// DOMZ：根据网址获取该网址的是否收录
        /// </summary>
        /// <param name="strWebUrl">网址: 上海云里网络科技有限公司.com or www.上海云里网络科技有限公司.com</param>
        /// <returns>返回该网址是否被DOMZ收录</returns>
        public static string GetDOMZResultByLinks(string strWebUrl)
        {
            string strGetResult = "0";

            try
            {
                strWebUrl = "http://www.dmoz.org/search?q=" + strWebUrl;
                SEO.Utility.WebClient wc = new SEO.Utility.WebClient();
                wc.Encoding = System.Text.Encoding.UTF8;
                wc.OpenRead(strWebUrl);
                string strGetHtmlCode = wc.RespHtml;
                if (strGetHtmlCode.Contains("Open Directory Categories"))
                {
                    strGetResult = "1";
                }
                else
                {
                    strGetResult = "0";
                }
            }
            catch (Exception ex)
            {
                SEO.Utility.Log.SaveErrorLog("抓取DOMZ搜索结果入口 -> " + ex.Message);
            }

            return strGetResult;
        }

        /// <summary>
        /// DOMZ：根据网址获取该网址的收录数量
        /// </summary>
        /// <param name="strWebUrl">网址: 上海云里网络科技有限公司.com or www.上海云里网络科技有限公司.com</param>
        /// <returns>返回该网址被DOMZ收录数量</returns>
        public static string GetDOMZResultNumByLinks(string strWebUrl)
        {
            string strGetResult = "0";

            try
            {
                strWebUrl = "http://www.dmoz.org/search?q=" + strWebUrl;
                SEO.Utility.WebClient wc = new SEO.Utility.WebClient();
                wc.Encoding = System.Text.Encoding.UTF8;
                wc.OpenRead(strWebUrl);
                string strGetHtmlCode = wc.RespHtml;
                if (strGetHtmlCode.Contains("Open Directory Categories"))
                {
                    strGetResult = "已收录";
                    // <small>(1-5 of 47)</small> 
                    Regex rx = new Regex("<h3>(?<content>[\\s\\S]*)?</h3>", RegexOptions.Singleline);
                    strGetResult = rx.Match(strGetHtmlCode).Result("${content}");

                    Regex rx2 = new Regex("of(?<content>[\\s\\S]*)?</small>", RegexOptions.Singleline);
                    strGetResult = rx2.Match(strGetResult).Result("${content}");
                    strGetResult = strGetResult.Replace(")", "");
                }
                else
                {
                    strGetResult = "0";
                }
            }
            catch (Exception ex)
            {
                SEO.Utility.Log.SaveErrorLog("抓取DOMZ搜索结果入口 -> " + ex.Message);
            }

            return strGetResult;
        }
    }
}
